﻿@model Yamfinder.Web.Models.SearchResultsModel

@{
    ViewBag.Title = "Search Lexical Database";
}

<h2>Search Lexical Database</h2>

<span>Time Taken: @Model.TimeTaken</span>
<span>Search Began: @Model.Timestamp</span>

<table>
    <tr>
        <th>@Model.Data.XAxisFieldname</th>
    </tr>
    <tr>
        <th>@Model.Data.YAxisFieldname</th>
    @for (int j = 0; j < Model.Data.ColumnCount; j++)
        {
        //First row is headers
        <th>@Model.Data.ColumnHeaders[j]</th>            
        }
    </tr>
    @for (int i = 0; i < Model.Data.RowCount; i++)
    {
            
    
    <tr>
        @for (int j = 0; j < Model.Data.ColumnCount; j++)
        {
            if (j == 0)
            {
                //Only for first column
                <th>@Model.Data.RowHeaders[i]</th> 
            }

            if (Model.Data[j, i] == null)
            {
                <td>Empty</td>
                continue;
            }

            var entry = Model.Data[j, i];
            
            <td>
                @foreach (var field in Model.FieldsToDisplay)
                {
                    if (entry.Fields.ContainsKey(field))
                    {
                        <p><b>@field</b>: @entry.Fields[field].ToString()</p>
                    }
                }
            
            </td>
        }
    </tr>
    }
</table>
